package com.yuke.cloud.service.uac;

import com.yuke.cloud.common.security.core.validate.code.sms.SmsCodeSender;
import com.yuke.cloud.service.uac.service.impl.UacSmsCodeSender;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import tk.mybatis.spring.annotation.MapperScan;

//在SpringBoot中，默认的Spring Security生效了的，此时的接口都是被保护的,
//Spring Security提供了一个默认的用户，用户名是user，而密码则是启动项目的时候自动生成的
//如果不想使用Spring Security，在Application启动类上（或者任意@Configure配置类上）增加如下注解exclude = {org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class}
//scanBasePackageClasses={YukeCoreConfig.class}放到需要的配置类中进行扫描加载，放在此处可能导致无法扫描到本项目中的包
@EnableHystrix
@EnableFeignClients
@EnableDiscoveryClient
@SpringBootApplication//(exclude = {org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class}/*, scanBasePackageClasses={YukeCoreConfig.class}*/)
//@ComponentScan(basePackages = { "com.yuke.cloud.service.uac","com.yuke.cloud.common.security.auth.app"} )  //add by wg 20180928 社交登录处理
@EnableTransactionManagement
@MapperScan(basePackages = "com.yuke.cloud.service.uac.dao")  //设置Mapper接口所在的包
public class YukeCloudServiceUacApplication {

    public static void main(String[] args) {
        SpringApplication.run(YukeCloudServiceUacApplication.class, args);
    }

    @Bean
    public ReloadableResourceBundleMessageSource messageSource() {
        ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
        messageSource.setBasename("classpath:org/springframework/security/messages_zh_CN");
        return messageSource;
    }

    @Bean
    public SmsCodeSender smsCodeSender() {
        return new UacSmsCodeSender();
    }
}
